using System;
using System.Collections.Generic;
using Vk.Methods.Audios;
using Vk.Methods.Common;
using Vk.Methods.Docs;
using Vk.Methods.Fave;
using Vk.Methods.Photos;
using Vk.Methods.Wall;

namespace Vk.Methods.Messages
{
    public class HistoryAttchments
    {
        public List<object> Items { get; }
        public string NextFrom { get; private set; }
        public MediaType Type { get; set; }

        public HistoryAttchments(ApiNode node, MediaType type)
        {
            Type = type;
            NextFrom = node.String("next_from");
            Items = new List<object>();
            foreach (var item in node.SelectNodes("items/*"))
            {
                switch (Type)
                {
                    case MediaType.Photo:
                        Items.Add(new Photo(item));
                        break;
                    case MediaType.Video:
                        Items.Add(new Video.Video(item));
                        break;
                    case MediaType.Audio:
                        Items.Add(new Audio(item));
                        break;
                    case MediaType.Doc:
                        Items.Add(new Document(item));
                        break;
                    case MediaType.Link:
                        Items.Add(new LinkInfo(item));
                        break;
                    case MediaType.Market:
                        throw new NotImplementedException();
                        break;
                    case MediaType.Wall:
                        Items.Add(new WallPost(item));
                        break;
                    case MediaType.Share:
                        //TODO
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }
        }
    }
}